#include<iostream>
#include<string>
using namespace std;
class Solution {
public:
    string reverseWords(string s) {
        int len = s.size();
        int left = 0;
        int right = 0;
        while (right < len) {
            while (s[right] != ' ') {
                if (right == len - 1) {
                    right++;
                    break;
                }
                right++;
            }
            reverse(s.begin() + left, s.begin() + right);
            right++;
            left = right;
        }
        reverse(s.begin() + left, s.end());
        return s;
    }
};
int main()
{
	return 0;
}